/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.ViewInStockSummary;
import com.ruipengkj.commons.base.query.BaseQuery;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.ViewInStockSummaryDao;
import com.ruipengkj.service.ViewInStockSummaryService;
/**
 * 说明：
 * 商品采购汇总表Service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class ViewInStockSummaryServiceImpl implements ViewInStockSummaryService{

	@Resource
	private ViewInStockSummaryDao ViewInStockSummary;//DAO层

	@Override
	public void deleteService(String id) throws Exception {
		
	}

	@Override
	public List<ViewInStockSummary> findService(
			ViewInStockSummary entity) throws Exception {
		return null;
	}

	@Override
	public ViewInStockSummary getByIdService(String id)
			throws Exception {
		return null;
	}

	@Override
	public PageModel<ViewInStockSummary> getScrollService(
			int firstResult, int maxResult, ViewInStockSummary entity)
			throws Exception {
		String hql = "select o from ViewInStockSummary o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(entity.getHappenTime()!=null&& !entity.getHappenTime().equals("")){
					whereHQL.append("o.happenTime >=?").append(BaseQuery.AND);
					param.add(entity.getHappenTime());
			}
			if(entity.getEndTime()!=null&& !entity.getEndTime().equals("")){
				whereHQL.append("o.happenTime <=?").append(BaseQuery.AND);
				param.add(entity.getEndTime());
			}
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return ViewInStockSummary.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	@Override
	public void modifyService(ViewInStockSummary entity)
			throws Exception {
		
	}

	@Override
	public void saveOrUpdateService(ViewInStockSummary entity)
			throws Exception {
		
	}

	@Override
	public Serializable saveRetService(ViewInStockSummary entity)
			throws Exception {
		return null;
	}

	@Override
	public void saveService(ViewInStockSummary entity)
			throws Exception {
		
	}

	public ViewInStockSummaryDao getViewInStockSummary() {
		return ViewInStockSummary;
	}

	public void setViewInStockSummary(ViewInStockSummaryDao ViewInStockSummary) {
		this.ViewInStockSummary = ViewInStockSummary;
	}
	
	@Override
	public List<ViewInStockSummary> findExportService(
			ViewInStockSummary entity) throws Exception {
		String hql = "select o from ViewInStockSummary o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(null!=entity.getHappenTime()&&!("").equals(entity.getHappenTime())){
				whereHQL.append("HappenTime>=?").append(BaseQuery.AND);
				param.add(entity.getHappenTime());
			}
			if(null!=entity.getEndTime()&&!("").equals(entity.getEndTime())){
				whereHQL.append("HappenTime<=?").append(BaseQuery.AND);
				param.add(entity.getEndTime());
			}
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return ViewInStockSummary.findDao(hql, whereHQL.toString(), param, orderby);
	}
}
